home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 2001 #11 / CD 11 (Black) - 2001.iso / Fruity / GUSHERS.DXR / 00007_JumpingGuyObj.ls < prev    next >
Encoding:
Text File  |  1998-04-13  |  5.7 KB  |  199 lines

  1. property pJGuyList, pJGuyCounter, pLastJGuyTime, pJGuyIntervalTime, pJGuyInterIntervalTime, pGuyAnimFlag, pUpMember, pDownMember, pLandMember, pGuyChan, pMoutainList
  2. global gGusherObj, gBlank
  3.  
  4. on new me
  5.   set pJGuyList to [28, 29, 30]
  6.   set pJGuyCounter to 1
  7.   set pLastJGuyTime to the timer
  8.   set pJGuyIntervalTime to 15
  9.   set pGuyAnimFlag to 0
  10.   set pUpMember to 31
  11.   set pDownMember to 32
  12.   set pLandMember to 33
  13.   set pGuyChan to 35
  14.   set pMoutainList to [118: [219, 0, 0], 249: [141, 0, 0], 405: [189, 0, 0]]
  15.   return me
  16. end
  17.  
  18. on mUpdateGuy me
  19.   if the timer < (pLastJGuyTime + pJGuyIntervalTime) then
  20.     exit
  21.   end if
  22.   set the castNum of sprite pGuyChan to getAt(pJGuyList, pJGuyCounter)
  23.   set pJGuyCounter to pJGuyCounter + 1
  24.   if pJGuyCounter = (count(pJGuyList) + 1) then
  25.     set pJGuyCounter to 1
  26.   end if
  27.   set pLastJGuyTime to the timer
  28. end
  29.  
  30. on mJumpRoutine me
  31.   puppetSnd(1, "StartJump")
  32.   set gusherList to the pGusherList of gGusherObj
  33.   set gusherList to mAddMoutains(me, gusherList)
  34.   set jumpCount to count(gusherList)
  35.   set iList to [0, 0, 0]
  36.   repeat with index = 1 to jumpCount
  37.     set lastiList to iList
  38.     set iList to getAt(gusherList, index)
  39.     set the memberNum of sprite pGuyChan to pUpMember
  40.     updateStage()
  41.     if index > 1 then
  42.       if getAt(lastiList, 2) = 0 then
  43.         puppetSnd(1, "MountainJump")
  44.       else
  45.         puppetSnd(1, "Gush")
  46.       end if
  47.     end if
  48.     mJump(me, pGuyChan, the locH of sprite pGuyChan, the locV of sprite pGuyChan, getPropAt(gusherList, index), getAt(iList, 1), getAt(lastiList, 2), getAt(lastiList, 3))
  49.   end repeat
  50.   set the memberNum of sprite pGuyChan to pUpMember
  51.   if getAt(iList, 2) = 0 then
  52.     puppetSnd(1, "MountainJump")
  53.   else
  54.     puppetSnd(1, "Gush")
  55.   end if
  56.   updateStage()
  57.   mJump(me, pGuyChan, the locH of sprite pGuyChan, the locV of sprite pGuyChan, 509, 127, getAt(iList, 2), getAt(iList, 3))
  58.   set the memberNum of sprite pGuyChan to pLandMember
  59.   puppetSnd(1, "MountainJump")
  60.   updateStage()
  61.   repeat while soundBusy(1)
  62.   end repeat
  63.   mWin(me)
  64. end
  65.  
  66. on mAddMoutains me, gusherList
  67.   set gusherList to duplicate(gusherList)
  68.   set gushercount to count(gusherList)
  69.   if gushercount = 0 then
  70.     return pMoutainList
  71.   end if
  72.   repeat with index = 1 to 3
  73.     set h to getPropAt(pMoutainList, index)
  74.     set nIndex to findPosNear(gusherList, h)
  75.     if nIndex > gushercount then
  76.       set nIndex to gushercount
  77.     end if
  78.     set nearest to getPropAt(gusherList, nIndex)
  79.     if nIndex > 1 then
  80.       set nearest2 to getPropAt(gusherList, nIndex - 1)
  81.       if abs(nearest2 - h) < abs(nearest - h) then
  82.         set nIndex to nIndex - 1
  83.         set nearest to nearest2
  84.       end if
  85.     end if
  86.     if not (abs(nearest - h) <= 5) then
  87.       addProp(gusherList, h, getAt(pMoutainList, index))
  88.       next repeat
  89.     end if
  90.   end repeat
  91.   return gusherList
  92. end
  93.  
  94. on mJump me, jumpChan, xo, yo, x2, y2, gusherChan, gusherMem
  95.   set deltaX to x2 - xo
  96.   set deltaY to y2 - yo
  97.   if (deltaX > 60) or (deltaY < -120) then
  98.     mJumpOff(me, gusherChan, gusherMem)
  99.     mLose(me)
  100.     abort()
  101.   end if
  102.   set a to max([abs(deltaY) + 40, 60])
  103.   if a > 100 then
  104.     set a to 90
  105.   end if
  106.   set steps to 20
  107.   set explodeCount to 4
  108.   repeat with t = 1 to steps
  109.     set theTime to the timer + 4
  110.     set newX to xo + integer(deltaX * float(t) / float(steps))
  111.     set newY to yo - (a * sin(PI * (float(t) / steps))) + integer(deltaY * float(t) / float(steps))
  112.     set the loc of sprite jumpChan to point(newX, newY)
  113.     if t > (steps / 2) then
  114.       set the memberNum of sprite pGuyChan to pDownMember
  115.     end if
  116.     if gusherMem then
  117.       if explodeCount > 0 then
  118.         set the memberNum of sprite gusherChan to gusherMem + (5 - explodeCount)
  119.         set explodeCount to explodeCount - 1
  120.       else
  121.         if the memberNum of sprite gusherChan <> gBlank then
  122.           set the memberNum of sprite gusherChan to gBlank
  123.           set the loc of sprite gusherChan to point(264, 260)
  124.         end if
  125.       end if
  126.     end if
  127.     UpdateSaturn()
  128.     UStage(theTime)
  129.   end repeat
  130. end
  131.  
  132. on mJumpOff me, gusherChan, gusherMem
  133.   set ├╕ to PI / 3.0
  134.   set vo to 50
  135.   set g to 8
  136.   set xo to the locH of sprite pGuyChan
  137.   set yo to the locV of sprite pGuyChan
  138.   set t to 1
  139.   set downflag to 0
  140.   set explodeCount to 4
  141.   repeat while the locV of sprite pGuyChan < 300
  142.     set theTime to the timer + 6
  143.     set oldY to the locV of sprite pGuyChan
  144.     set newX to xo + (vo * cos(├╕) * t)
  145.     set newY to yo - ((vo * sin(├╕) * t) - (g * power(t, 2)))
  146.     if (newY > oldY) and not downflag then
  147.       set the memberNum of sprite pGuyChan to pDownMember
  148.       puppetSnd(1, "fall2")
  149.       set downflag to 1
  150.     end if
  151.     set the locH of sprite pGuyChan to newX
  152.     set the locV of sprite pGuyChan to newY
  153.     set t to t + 1
  154.     if gusherMem then
  155.       if explodeCount > 0 then
  156.         set the memberNum of sprite gusherChan to gusherMem + (5 - explodeCount)
  157.         set explodeCount to explodeCount - 1
  158.       else
  159.         if the memberNum of sprite gusherChan <> gBlank then
  160.           set the memberNum of sprite gusherChan to gBlank
  161.           set the loc of sprite gusherChan to point(264, 260)
  162.         end if
  163.       end if
  164.     end if
  165.     UStage(theTime)
  166.   end repeat
  167.   repeat while soundBusy(1)
  168.   end repeat
  169. end
  170.  
  171. on mLose me
  172.   resetGame()
  173. end
  174.  
  175. on mWin me
  176.   puppetSnd(1, "win")
  177.   updateStage()
  178.   repeat while soundBusy(1)
  179.     repeat with offset = 1 to 4
  180.       set theTime to the timer + 10
  181.       set the memberNum of sprite pGuyChan to pLandMember + offset - 1
  182.       UpdateSaturn()
  183.       UStage(theTime)
  184.       if not soundBusy(1) then
  185.         exit repeat
  186.       end if
  187.     end repeat
  188.   end repeat
  189.   if IsShockWave() then
  190.     gotoNetPage("../guxst.html")
  191.   else
  192.     if IsProj() then
  193.       go(1, "STRINGTG")
  194.     else
  195.       resetGame()
  196.     end if
  197.   end if
  198. end
  199.